﻿package com.rragona.utils.drawing 
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.JointStyle;
	import flash.display.CapsStyle;
	import flash.display.LineScaleMode;
	
	/**
	* ...
	* @author rragona
	*/
	public class CustomDraw extends Sprite
	{
		
		public function CustomDraw() 
		{
			trace('This is a static class, and should not be constructed.');
		}
		
		public static function drawBox(w:Number, h:Number, color:uint = 0x777777, alpha:Number = 1, strokeWidth:Number = NaN, strokeColor:uint = 0, strokeAlpha:Number = 1.0):Sprite
		{
			var retSprite:Sprite = new Sprite();
			
			retSprite.graphics.lineStyle( strokeWidth, strokeColor, strokeAlpha, true, LineScaleMode.NONE, CapsStyle.SQUARE, JointStyle.MITER );
			retSprite.graphics.beginFill(color, alpha);
			retSprite.graphics.drawRect(0, 0, w, h);
			retSprite.graphics.endFill();
			
			return retSprite;
		}
		
		public static function drawRoundBox(w:Number, h:Number,  cSize:int, color:uint = 0x777777, alpha:Number = 1, strokeWidth:Number = NaN, strokeColor:uint = 0, strokeAlpha:Number = 1.0):Sprite
		{
			var retSprite:Sprite = new Sprite();
			
			retSprite.graphics.lineStyle( strokeWidth, strokeColor, strokeAlpha, true, LineScaleMode.NONE, CapsStyle.SQUARE, JointStyle.MITER );
			retSprite.graphics.beginFill(color, alpha);
			retSprite.graphics.drawRoundRect(0, 0, w, h, cSize);
			retSprite.graphics.endFill();
			
			return retSprite;
		}
		
		public static function drawTri(size:Number):Sprite
		{
			var retSprite:Sprite = new Sprite();
			
			retSprite.graphics.beginFill(0xFFFFFF, 0.7);
			retSprite.graphics.lineTo(size * .5, size * .5);
			retSprite.graphics.lineTo(0, size);
			retSprite.graphics.endFill();
			
			return retSprite;
		}
		
		public static function dottedLine(length:Number, pixelSize:int, spacing:Number, color:uint = 0x000000):Sprite
		{
			var retSprite:Sprite = new Sprite();
			
			var numDots = length / spacing;
			
			for (var z:int = 0; z < numDots; z ++)
			{
				var dot:Shape = new Shape()
				
				dot.graphics.beginFill(color);
				dot.graphics.drawRect(0, 0, pixelSize, pixelSize);
				
				dot.y = int(z * spacing);
				
				retSprite.addChild(dot);
			}
			
			return retSprite;
		}
		
	}
	
}